package org.giovanolli.mumi.dao.impl;

import org.giovanolli.mumi.dao.PatientLogDao;
import org.giovanolli.mumi.entities.PatientLog;
import org.giovanolli.mumi.entities.filter.EntityFilter;
import org.giovanolli.mumi.entities.filter.PatientLogFilter;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

/**
 * The Class PatientLogDaoImpl.
 */
@Repository("patientLogDao")
public class PatientLogDaoImpl extends HibernateDao<PatientLog> implements PatientLogDao {

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.giovanolli.mumi.dao.impl.HibernateDao#fillCriteria(org.giovanolli .mumi.entities.filter.EntityFilter, org.hibernate.criterion.DetachedCriteria)
	 */
	@Override
	protected DetachedCriteria fillCriteria(EntityFilter<PatientLog> filter, DetachedCriteria criteria) {
		final PatientLogFilter entityFilter = (PatientLogFilter) filter;

		if (entityFilter != null) {
			if (entityFilter.getPatient() != null) {
				criteria.add(Restrictions.eq("patient", entityFilter.getPatient()));
			}
		}
		return criteria;
	}

}
